package com.hkd.cya.状态模式;

public abstract class AbstractState {

    protected Student student;

    protected String stateName;//黄色 蓝色 绿色

    public AbstractState(Student student) {

        this.student = student;

    }



    public String getStateName() {

        return stateName;

    }  public abstract void checkState();



    public void playGame() {




        // 打印玩游戏并扣除积分的信息

        System.out.println("---开心打游戏，扣除积分20------");

        student.setAccountPoints(student.getAccountPoints() - 20);

        //补全代码4

        checkState();

        System.out.println("剩余积分为：" + student.getAccountPoints()  + "，当前状态为：" + student.getState().getStateName() + "。");

        System.out.println("-------------------------------");



    }



    public void study() {

        System.out.println("-------学习辛苦了,获得20积分-------");

        //补全代码5

        student.setAccountPoints(student.getAccountPoints()+20);

        checkState();

        System.out.println("当前积分为：" + student.getAccountPoints()+ "，当前状态为：" + student.getState().getStateName() + "。");

        System.out.println("-------------------------------");

    }



    public void recommend() {

        System.out.println("你的积分不够，没有保研资格，加油加油");

    }



}
